$(function() {
	 var table = layui.table
	,form = layui.form
	,laydate = layui.laydate;
	laydate.render({
	  elem: '.plan_time'
	  ,type: 'datetime'
	});
	
	laydate.render({
	  elem: '.arriver_time'
	  ,type: 'datetime'
	});
	$("#loading-first").fadeOut(500);
	var where_json={};
	where_json.order_id=['in',{$Think.get.order_id}]
	Load()
	$.ajax({
		type:"post",
		url:"{:url('adminapi/Order/orderList')}",
		data:{
			where_json:JSON.stringify(where_json)
		},
		success:function(res1){
			Load(1)
			console.log(res1)
			console.log(res1.data[0].pay_type)
			for(var key in res1.data[0]){
				$('.'+key).html(res1.data[0][key])
			}
			//选择车辆
			var where_json3={};
			var car_list=`<option>请选择车辆</option>`
			{if $company.company_mode==1}
			if(res1.data[0].pay_type==4){
				where_json3.company_id=['in',"{$company.company_id}"]
				where_json3.entrust_company_id=['=',0]
			}else{
				where_json3.company_id=['in',"{$company.company_id}"]
			}
			{elseif $company.company_mode==2/}
			if(res1.data[0].pay_type==4){
				where_json3.company_id=['in',"{$company.company_id}"]
				where_json3.entrust_company_id=['=',0]
			}else{
				where_json3["company_id|entrust_company_id"]=['in',"{$company.company_id}"]
			}
			{/if}
			var carload = layer.load(0, {shade: false});
			let where_json2={};
			where_json2.company_id=['in',"{$company.company_id}"]
			var driverload = layer.load(0, {shade: false});
			$.ajax({
				type:"post",
				url:"{:url('adminapi/driver/driverList')}",
				data:{
					page:1,
					pagenum:999999,
					where_json:JSON.stringify(where_json2)
				},
				success:function(res){
					layer.close(driverload)
					console.log(res)
					console.log('赋值 ')
		            let driver_list='<option>请选择司机</option>';
					for(let didx=0;didx<res.data.length;didx++){
						driver_list+=`<option value="${res.data[didx].driver_id}">${res.data[didx].name}</option>`
					}
					console.log('zhixing ');
		            $('#driver_id').html(driver_list);
					form.render('select');
					
				}
			});
			$.ajax({
				type:"post",
				url:"{:url('adminapi/Car/carList')}",
				data:{
					page:1,
					pagenum:999999,
					where_json:JSON.stringify(where_json3)
				},
				success:function(res){
					layer.close(carload)
					console.log(res)
					for(var cidx=0;cidx<res.data.length;cidx++){
						car_list+=`<option value="${res.data[cidx].car_id}">${res.data[cidx].number}</option>`
					}

					$('#car_id').html(car_list)
					form.render('select');
                   
				}
			});
			$('.dispatch').on('click', function() {
				sendForm($(this),1,"{:url('index')}");
			})
		}
	});
	
	



}


)